#ifndef TEXTEDIT_H
#define TEXTEDIT_H


#include "main.h"
#include <QtCore>
#include <QApplication>
#include <QtGui>
#include <QTextEdit>
#include "highlighter.h"
#include <QAbstractItemModel>
#include <QCompleter>
#include <QStringListModel>
#include <QShortcut>
#include <QTextCodec>
#include <QSettings>
#include <QClipboard>
#include <QMessageBox>
#include <QtDebug>
#include <QDebug> 
#include <QDesktopServices>
#include <QDebug>
#include <QString>
#include <QSqlError>
#include <QSqlQuery>
#include <QSqlTableModel>
#include <QSqlRelationalTableModel>
#include <QSqlRelationalDelegate>
#include <QHeaderView>
#include <QSqlRecord>
#include <QSqlDatabase>
#include <QMap>
#include <QList>
#include <QStringList>

#include "dbword.h"








typedef enum
{  
  MIMEUTF8,
  MIMEISO,
  NO_EFFECT
} OPENMODUS;



class TextEdit : public QTextEdit
{
    Q_OBJECT

public:
    TextEdit(QWidget *parent = 0);
    ~TextEdit();
    void RebuildCompleter();
    void selectLines(int debut, int fin);
    Highlighter *highlighter;
    void setCompleter(QCompleter *c);
    QAbstractItemModel *modelFromFile(const QString& fileName);
    QCompleter *completer() const;
    void SetFile( const QString onefile , OPENMODUS modus );
    void SetDBinit( DBword * dbin );
    inline QString GetFileName() { return filefull; }
    inline QString GetKeyWords() { return KeyWord; }
    inline bool HavingFile() { return havingfile; }
    inline OPENMODUS GetModus() { return mode; }
    void SetParent( QTextEdit * under );
    QString textUnderCursor() const;
    QString currentTXTsel;
    QString grepword;
    QString KeyWord;
    qreal  fontsize;
    inline void SetID( int n ) { currentid = n; }
    inline int GetID() { return currentid; }
    int currentid;
    QSettings setter;
protected:
    void keyPressEvent(QKeyEvent *e);
    void contextMenuEvent( QContextMenuEvent *e );
    void focusInEvent(QFocusEvent *e);
    /////void dragEnterEvent(QDragEnterEvent *e);
    /////void dropEvent(QDropEvent *e);
    void IndentText( bool make );
    DBword *WordDB;
    QString KeywordGenerator( QString text );
    QTextCursor LastTabCursor;
    QTextCursor CurrentCursor;
    QClipboard  *baseram;
    QString GrepTextLines(int startline, int stopline );
    QString GrepLineFromTxBloc( QTextBlock block );
    QCompleter *completerbase;
    QShortcut *shortcut7;
    QShortcut *shortcut8;
    QShortcut *closetab;
    QShortcut *shfind;
    QShortcut *shsavefile;
    QShortcut *newfilefile;
    QShortcut *shfireplace;
    bool parentlineok;
    bool m_tabSpaces;
    QString filefull;
    int loadwordsum;
    QStringList wordcurrentappend;
    OPENMODUS mode;
    bool havingfile;
    QTextEdit *textfriend;
  signals:
    void FileSaveTo(QString);
    void OpenFilesmore(QStringList);
    void CloseTab();
    void NewFileOpen();
    void SearchText();
private slots:
    void insertCompletion( QString completion );
    void UpdateSourceLine();
    void AppendCurrentWord();
    void initialize();
public slots:
    void IncreaseFont();
    void DecreaseFont();
    void Textreapaint();
    void TextSave();
    void TSaveAS();
    void closetabulatorhere();
    void ParentFont();
    void QueryFind();
    void ExportWord();
    void NewFileMake();

private:
    QCompleter *c;

   
};

#endif // TEXTEDIT_H

